<?php
	require_once '../Tool/Common/PrepareInput.php';

    session_start();
    if (empty($_SESSION["userType"])) {
        $url="../Index.php";
		include_once '../Tool/Common/Redirect.php';
		exit();
    }
    
    $NRIC=$ActivityCentre=$ActivityId=$Performance=$Remarks="";  

    if(isset($_REQUEST['NRIC'])){ 
        $NRIC=prepareInput($_REQUEST['NRIC']); 
    }
    if(isset($_REQUEST['ActivityCentre'])) { 
        $ActivityCentre=prepareInput($_REQUEST['ActivityCentre']); 
    }
    if(isset($_REQUEST['ActivityId'])) { 
        $ActivityId=prepareInput($_REQUEST['ActivityId']); 
    }
    if(isset($_REQUEST['Performance'])) { 
        $Performance=prepareInput($_REQUEST['Performance']); 
    }
    if(isset($_REQUEST['Remarks'])) { 
        $Remarks=prepareInput($_REQUEST['Remarks']); 
    }

    $result=array();

    $result['flagNRIC']=0;
    $result['flagActivityCentre']=0;  
    $result['ActivityId']=0;
    $result['flagPerformance']=0;  
    $result['flagRemarks']=0;

    if(!empty($NRIC)&&preg_match("/^[ST][0-9]{7}[JZIHGFEDCBA]$/",$NRIC)||preg_match('/^[FG][0-9]{7}[XWUTRQPNMLK]$/', $NRIC)){
        $result['flagNRIC']=1;
    }
    if(preg_match("/^[0-9]*$/",$ActivityCentre)&&!empty($ActivityCentre)){
        $result['flagActivityCentre']=1;
    }
    if(preg_match("/^[0-9A-Za-z ]*$/",$ActivityId)&&!empty($ActivityId)){
        $result['ActivityId']=1;
    } 
    if(preg_match("/^[0-9]*$/",$Performance)&&!empty($Performance)){
        $result['flagPerformance']=1;
    } 
    if(preg_match("/^[0-9A-Za-z \s]*$/",$Remarks)&&!empty($Remarks)){
        $result['flagRemarks']=1;
    }
    if(empty($Remarks)){
        $result['flagRemarks']=1;
    }

    echo json_encode($result);
?>